package io.renren.config;

import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @ClassName WxMinConfig
 * @Description TODO
 * @Author Jll
 * @Date 2024/6/24 16:35
 * @Version 1.0
 */
@Configuration
public class WxMinConfig {

    @Resource
    private WxPayConfig wxPayConfig;

    @Bean
    public WxMaService wxMaService(){
        WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
        config.setAppid(wxPayConfig.getAppId());
        config.setSecret(wxPayConfig.getAppSecret());
        config.setMsgDataFormat(wxPayConfig.getMsgDataFormat());
        WxMaService service = new WxMaServiceImpl();
        service.setWxMaConfig(config);
        return service;
    }
}
